package ru.vsu.cs.pm;

import org.apache.wicket.Page;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.settings.ISecuritySettings;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.wicketstuff.annotation.scan.AnnotatedMountScanner;
import ru.vsu.cs.pm.pages.HomePage;

/**
 * Application object for your web application. If you want to run this application without deploying, run the Start class.
 * 
 */
public class WicketApplication extends WebApplication
{    

    @Override
    protected void init() {
        addComponentInstantiationListener(new SpringComponentInjector(this));

        new AnnotatedMountScanner().scanPackage("ru.vsu.cs.pm.pages").mount(this);

        AuthStrategy authorizationStrategy = new AuthStrategy();
        ISecuritySettings securitySettings = getSecuritySettings();
        securitySettings.setAuthorizationStrategy(authorizationStrategy);
        securitySettings.setUnauthorizedComponentInstantiationListener(authorizationStrategy);
    }
	
	/**
	 * @see org.apache.wicket.Application#getHomePage()
	 */
	public Class<? extends Page> getHomePage()
	{
		return HomePage.class;
	}

    @Override
    public Session newSession(Request request, Response response) {
        // using our own session
        return new PMSession(request);
    }
}
